Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Conversation

acheroncrypto
Copy link
Contributor

Problem

SendTransactionRpc implementation of ProgramRpcClientSendTransaction both sends and confirms the transaction:

impl SendTransactionRpc for ProgramRpcClientSendTransaction {
fn send<'a>(
&self,
client: &'a RpcClient,
transaction: &'a Transaction,
) -> BoxFuture<'a, ProgramClientResult<Self::Output>> {
Box::pin(async move {
if !transaction.is_signed() {
return Err("Cannot send transaction: not fully signed".into());
}
client
.send_and_confirm_transaction(transaction)
.await
.map(RpcClientResponse::Signature)
.map_err(Into::into)
})
}
}

The behavior is misleading, especially considering its naming, and it's also the root cause of the problem mentioned in #7595.

Summary of changes

  • Convert ProgramRpcClientSendTransaction to a named struct and add confirm field
  • Use the confirm field to decide whether to confirm the sent transaction
  • Add new and new_with_confirmation methods to the ProgramRpcClientSendTransaction struct
  • Use ProgramRpcClientSendTransaction::new during token-cli's Config creation
  • Use ProgramRpcClientSendTransaction::new_with_confirmation everywhere else in the repository to keep the changes minimal and behavior the same

Note: I found this solution to be simpler than adding a new type (like mentioned in #3139 (review)), but I'd be down to implement it that way too if that's what you prefer.

Fixes #7595

@mergify mergify bot added the community Community contribution label Dec 17, 2024
@github-actions github-actions bot added the stale [bot only] Added to stale content; will be closed soon label Jan 1, 2025
@buffalojoec buffalojoec self-requested a review January 7, 2025 07:15
@github-actions github-actions bot removed the stale [bot only] Added to stale content; will be closed soon label Jan 7, 2025
@github-actions github-actions bot added the stale [bot only] Added to stale content; will be closed soon label Feb 27, 2025
@github-actions github-actions bot closed this Mar 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community Community contribution stale [bot only] Added to stale content; will be closed soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spl-token transfer --no-wait still waits for transaction to confirm
1 participant